#!/bin/bash

IFS=$'\n'

files=`ls merged | grep .csv`
here=`pwd`/merged
there=`pwd`/results

rm $there/*

for file in $files ; do
	name=$there/$file
	dname=$here/$file
	echo Source:
	echo $name
	echo Destination:
	echo $dname
	echo
	cat $dname | awk -F\",\" '{print $3}' | sort | uniq -c | awk '{print $2","$1}' >> $name
done


#cat $dname | awk -F\",\" '{print $3}' | sort | uniq -c
#cat $dname | awk -F\",\" '{print $3}' | sort | uniq -c | awk '{print $2","$1}'
#cat $dname | awk -F\",\" '{print $3}' | awk -F- '{print $1,$2,$3}' | sort | uniq -c | awk '{print $2","$3","$4","$1}'

